home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / extras / programm / a56 / examples / reverb.lis < prev    next >
File List  |  1995-04-27  |  18KB  |  509 lines

  1.               ;***************************************************************
  2.               ; 
  3.               ; A stereo reverb for the DSP56001 signal processor.
  4.               ; Developed by Quinn Jensen (jensenq@qcj.icon.com) using
  5.               ; Dr. Vercoe and company's csound code as a reference for the 
  6.               ; configuration and gain values.
  7.               ; 
  8.               ;       NOTE - A much improved reverb algorithm is in sixcomb.a56
  9.               ; 
  10.               ; This program fragment implements a stereo reberb effect
  11.               ; on a DSP56001 processor.  The "depth" and wet/dry mix are
  12.               ; adjustable.  The following filter configuration is employed:
  13.               ;
  14.               ;
  15.               ;  Left in ------+------- "dry" gain -----------> sum -----> Left out
  16.               ;                |                                 ^
  17.               ;                v                                 |
  18.               ;               sum --> reverb --> "wet" gain -----+
  19.               ;                ^                                 |
  20.               ;                |                                 v -
  21.               ;  Right in -----+------- "dry" gain -----------> sum -----> Right out
  22.               ;
  23.               ;
  24.               ; Note that the reverb path output is negated before summing with the
  25.               ; right input signal.  This throws in 180 degrees of phase shift
  26.               ; making for interesting results even with mono inputs 
  27.               ; (i.e. Left in == Right in).
  28.               ; 
  29.               ; The reverb element looks like this:
  30.               ;
  31.               ;
  32.               ; Input ----+-----> comb1 ------+
  33.               ;           |                   |
  34.               ;           +-----> comb2 ---\  v
  35.               ;           |                  sum -----> allpass1 --> allpass2 ---> output
  36.               ;           +-----> comb3 ---/  ^
  37.               ;           |                   |
  38.               ;           +-----> comb4 ------+
  39.               ;
  40.               ; Each comb stage looks like this:
  41.               ;
  42.               ;                        +---- gain <-----+
  43.               ;                        |                |
  44.               ;                        v                |
  45.               ; Input ---> gain ----> sum ---> delay ---+--> out
  46.               ;
  47.               ;
  48.               ; The allpass stages look like:
  49.               ;
  50.               ;                         +--------- gain <---------+
  51.               ;                         |                         |
  52.               ;                         v                         |
  53.               ; Input ---> gain --+--> sum ---> delay ---> sum ---+----> out
  54.               ;                   |                         ^
  55.               ;                   |                         |
  56.               ;                   +--------> gain ----------+
  57.               ;
  58.               ; or,
  59.               ;
  60.               ;                             +-------> gain ----+
  61.               ;                             |                  |
  62.               ;                             |                  v
  63.               ; Input ---> gain ----> sum --+--> delay --+--> sum -----> out
  64.               ;                        ^                 |
  65.               ;                        |                 |
  66.               ;                        +----- gain <-----+
  67.               ;
  68.               ;
  69.               ; I've seen both configurations in the literature, so I plotted the
  70.               ; Z-transform and they are equivalent in the steady state.  They are indeed
  71.               ; all-pass in the steady state but are supposed to have a subtle, discernable
  72.               ; effect in "transient" audio signals.
  73.               ;
  74.               ; I think it could really use a couple more comb stages to fill in some of the 
  75.               ; graininess.  The best possible "diffusion" is desired.  By the way, 
  76.               ; I'd enjoy seeing any optimizations to the code.
  77.               ;
  78.               
  79.               ;hardware specific initialization code
  80.               
  81.               include "tdsg.a56"
  82.               
  83.               ;***************************************************************
  84.               ;
  85.               ;       Data and constants
  86.               ;
  87.               ;***************************************************************
  88.               
  89. P:0076        dot                             ;remember where we were in P-space
  90. X:0010                org     x:$10           ;put runtime variables in on-chip X-space
  91.               
  92.               ; A spreadsheet was used to calculate the following numbers
  93.               ;
  94.               ; The gain of each feedback stage is given by
  95.               ;
  96.               ;       feedback gain = exp(delay * ln(.001)/duration)
  97.               ;
  98.               ; where "delay" is the delay of the comb or allpass stage in seconds,
  99.               ; and "duration" is the time in seconds for the reverberated sound
  100.               ; to decay to 1/1000 of its original amplitude.
  101.               ;
  102.               
  103.               ;  Reverb filter lengths and coefficients  
  104.               ;  Sun Aug  4 16:36:16 1991    
  105.               ;  
  106.               ;      Sample rate               32.5520830 kHz      
  107.               ;      Reverb duration            4.0000000 s        
  108.               ;  
  109.               ;  stage    delay(ms)    length        gain    actual
  110.               ;  -----------------------------------------------------       
  111.               ;  Comb1   29.7000000       967   0.9500031     29.71
  112.               ;  Comb2   37.1000000      1208   0.9379399     37.11
  113.               ;  Comb3   41.1000000      1338   0.9314831     41.10
  114.               ;  Comb4   43.7000000      1423   0.9273101     43.71
  115.               ;  All-1    5.0000000       163   0.9914025      5.01
  116.               ;  All-2    1.7000000        55   0.9970685      1.69
  117.               
  118.   0.340909    in_atten equ                      0.3409091
  119.  0.0416667    comb_atten equ                    0.0416667
  120.        0.4    dry_init equ                      0.4000000     ; initial "dry" gain
  121.       0.99    reverb_init equ                   0.9900000     ; initial "wet" gain
  122.               
  123.               ; comb 1 data and parameters
  124.               
  125. 004000        c1d equ                   $4000
  126. X:0010 004000 c1r  dc                     c1d
  127. 0003C6        c1m equ                     966
  128.   0.950003    c1c equ                           0.9500031
  129.               
  130.               ; comb 2 data and parameters
  131.               
  132. 004800        c2d equ          c1d+      2048
  133. X:0011 004800 c2r  dc                     c2d
  134. 0004B7        c2m equ                    1207
  135.    0.93794    c2c equ                           0.9379399
  136.               
  137.               ; comb 3 data and parameters
  138.               
  139. 005000        c3d equ          c2d+      2048
  140. X:0012 005000 c3r  dc                     c3d
  141. 000539        c3m equ                    1337
  142.   0.931483    c3c equ                           0.9314831
  143.               
  144.               ; comb 4 data and parameters
  145.               
  146. 005800        c4d equ          c3d+      2048
  147. X:0013 005800 c4r  dc                     c4d
  148. 00058E        c4m equ                    1422
  149.    0.92731    c4c equ                           0.9273101
  150.               
  151.               ; allpass 1 data and parameters
  152.               
  153. 006000        a1d equ          c4d+      2048
  154. X:0014 006000 a1r  dc                     a1d
  155. 0000A2        a1m equ                     162
  156.   0.991403    a1c equ                           0.9914025
  157.               
  158.               ; allpass 2 data and parameters
  159.               
  160. 006800        a2d equ          a1d+      2048
  161. X:0015 006800 a2r  dc                     a2d
  162. 000036        a2m equ                      54
  163.   0.997068    a2c equ                           0.9970685
  164.               
  165. Y:0000                org     y:$0
  166.               
  167.       0.99    reverb_on equ   reverb_init
  168. 000000        reverb_off equ  0
  169.               
  170. Y:0000        reverb_gain
  171. Y:0000 7EB852         dc      reverb_on
  172. Y:0001        dry_gain
  173. Y:0001 333333         dc      dry_init
  174.               
  175. P:0076                org     p:dot           ;go back to P-space
  176.               
  177.               ;*****************************************************
  178.               ;
  179.               ; reverb initialization code
  180.               ;
  181.               ;*****************************************************
  182.               
  183. P:0076        hf_init
  184. P:0076 00000C         rts
  185.               
  186.               ;*****************************************************
  187.               ;
  188.               ; run-time controls
  189.               ;
  190.               ;*****************************************************
  191.               
  192. P:0077        eff1_on         ;enable reverb
  193. P:0077 46F400         move                    #reverb_on,y0
  194. P:0078 7EB852
  195. P:0079 4E0000         move                    y0,y:<reverb_gain
  196. P:007A 00000C         rts
  197.               
  198. P:007B        eff1_off        ;bypass reverb
  199. P:007B 46F400         move                    #reverb_off,y0
  200. P:007C 000000
  201. P:007D 4E0000         move                    y0,y:<reverb_gain
  202. P:007E 00000C         rts
  203.               
  204.               ;*****************************************************
  205.               ;
  206.               ; interrupt time calculations
  207.               ;
  208.               ;*****************************************************
  209.               
  210.               ;
  211.               ; fs = 32.552083 kHz
  212.               ;
  213.               
  214. P:007F        hf_comp
  215. P:007F 0D0066         jsr     <saveregs
  216.               ;
  217.               ;       L/R mix
  218.               ;
  219. P:0080 45F413         clr     a       #in_atten,x1            ;clr a, get scale for mix
  220. P:0081 2BA2E9
  221. P:0082 448000         move            x:<in_l,x0              ;get left in
  222. P:0083 440200         move            x0,x:<in_ls             ;save
  223. P:0084 4481A3         macr    x0,x1,a x:<in_r,x0              ;a = scale * left, get right
  224. P:0085 4403A3         macr    x0,x1,a x0,x:<in_rs             ;a += scale * right, save right
  225. P:0086 21C61B         clr     b               a,y0            ;y0 goes to the combs, b is sum
  226.               ;
  227.               ;       comb 1 
  228.               ;
  229. P:0087 609000         move            x:<c1r,r0
  230. P:0088 05F420         movec           #c1m,m0
  231. P:0089 0003C6
  232. P:008A 20CE00         move                    y0,a
  233. P:008B 45E000         move            x:(r0),x1
  234. P:008C 44F468         add     x1,b    #c1c,x0
  235. P:008D 7999B4
  236. P:008E 2000A3         macr    x0,x1,a
  237. P:008F 565800         move            a,x:(r0)+
  238. P:0090 601000         move            r0,x:<c1r
  239.               ;
  240.               ;       comb 2
  241.               ;
  242. P:0091 609100         move            x:<c2r,r0
  243. P:0092 05F420         movec           #c2m,m0
  244. P:0093 0004B7
  245. P:0094 20CE00         move                    y0,a
  246. P:0095 45E000         move            x:(r0),x1
  247. P:0096 44F468         add     x1,b    #c2c,x0
  248. P:0097 780E6A
  249. P:0098 2000A3         macr    x0,x1,a
  250. P:0099 565800         move            a,x:(r0)+
  251. P:009A 601100         move            r0,x:<c2r
  252.               ;
  253.               ;       comb 3
  254.               ;
  255. P:009B 609200         move            x:<c3r,r0
  256. P:009C 05F420         movec           #c3m,m0
  257. P:009D 000539
  258. P:009E 20CE00         move                    y0,a
  259. P:009F 45E000         move            x:(r0),x1
  260. P:00A0 44F468         add     x1,b    #c3c,x0
  261. P:00A1 773AD7
  262. P:00A2 2000A3         macr    x0,x1,a
  263. P:00A3 565800         move            a,x:(r0)+
  264. P:00A4 601200         move            r0,x:<c3r
  265.               ;
  266.               ;       comb 4
  267.               ;
  268. P:00A5 609300         move            x:<c4r,r0
  269. P:00A6 05F420         movec           #c4m,m0
  270. P:00A7 00058E
  271. P:00A8 20CE00         move                    y0,a
  272. P:00A9 45E000         move            x:(r0),x1
  273. P:00AA 44F468         add     x1,b    #c4c,x0
  274. P:00AB 76B219
  275. P:00AC 2000A3         macr    x0,x1,a
  276. P:00AD 565800         move            a,x:(r0)+
  277. P:00AE 601300         move            r0,x:<c4r
  278.               ;
  279.               ;       scale
  280.               ;
  281. P:00AF 12B400         move            #comb_atten,x0  b,y0
  282. P:00B0 055556
  283. P:00B1 2000D9         mpyr    x0,y0,b
  284.               
  285.               ;
  286.               ;       allpass 1
  287.               ;
  288. P:00B2 609400         move            x:<a1r,r0
  289. P:00B3 05F420         movec           #a1m,m0
  290. P:00B4 0000A2
  291. P:00B5 44F400         move            #a1c,x0
  292. P:00B6 7EE647
  293. P:00B7 45E000         move            x:(r0),x1
  294. P:00B8 20AEAB         macr    x0,x1,b x1,a
  295. P:00B9 21E600         move                    b,y0
  296. P:00BA 5758D7         macr    -x0,y0,a b,x:(r0)+
  297. P:00BB 601400         move            r0,x:<a1r
  298.               ;
  299.               ;       allpass 2
  300.               ;
  301. P:00BC 609500         move            x:<a2r,r0
  302. P:00BD 05F420         movec           #a2m,m0
  303. P:00BE 000036
  304. P:00BF 44F400         move            #a2c,x0
  305. P:00C0 7F9FF1
  306. P:00C1 45E000         move            x:(r0),x1
  307. P:00C2 20AFA3         macr    x0,x1,a x1,b
  308. P:00C3 21C600         move                    a,y0
  309. P:00C4 5658DF         macr    -x0,y0,b a,x:(r0)+
  310. P:00C5 601500         move            r0,x:<a2r
  311.               ;
  312.               ;       output mix
  313.               ;
  314. P:00C6 21E400         move            b,x0
  315. P:00C7 4E8000         move                    y:<reverb_gain,y0
  316. P:00C8 4E81D9         mpyr    x0,y0,b         y:<dry_gain,y0
  317. P:00C9 448200         move            x:<in_ls,x0
  318. P:00CA 21EE00         move            b,a
  319. P:00CB 4483D3         macr    x0,y0,a x:<in_rs,x0
  320. P:00CC 5604DB         macr    x0,y0,b a,x:<out_l
  321. P:00CD 570500         move            b,x:<out_r
  322.               
  323. P:00CE 0D006F         jsr     <restregs
  324. P:00CF 00000C         rts
  325.               
  326.                       end
  327.               
  328.  
  329. Summary of psect usage
  330.  
  331.                  section seg base last top      used       avail    total
  332. -------------------------------------------------------------------------
  333.  
  334.  
  335. Symbol Table
  336. -------------------------------------
  337.          ssi_int 000061
  338.             ssix 000010
  339.         eff1_off 00007B
  340.          eff1_on 000077
  341.         in_atten 0.3409091000
  342.      init_stereo 000059
  343.            start 000040
  344.            in_rs 000003
  345.            in_ls 000002
  346.             in_r 000001
  347.             in_l 000000
  348.              dot 000076
  349.       comb_atten 0.0416667000
  350.         mainloop 000060
  351.          hf_comp 00007F
  352.          hf_init 000076
  353.         saveregs 000066
  354.            savey 00000B
  355.            savex 00000A
  356.           saveb2 000009
  357.          saveb10 000008
  358.           savea2 000007
  359.          savea10 000006
  360.         dry_gain 000001
  361.         dry_init 0.4000000000
  362.      reverb_gain 000000
  363.       reverb_off 000000
  364.        reverb_on 0.9900000000
  365.      reverb_init 0.9900000000
  366.         restregs 00006F
  367.            out_r 000005
  368.            out_l 000004
  369.           m_scl1 00000F
  370.           m_scl0 00000E
  371.            m_scl 00C000
  372.           m_ssl1 00000D
  373.           m_ssl0 00000C
  374.            m_ssl 003000
  375.           m_hpl1 00000B
  376.           m_hpl0 00000A
  377.            m_hpl 000C00
  378.           m_ibl2 000005
  379.           m_ibl1 000004
  380.           m_ibl0 000003
  381.            m_ibl 000038
  382.           m_ial2 000002
  383.           m_ial1 000001
  384.           m_ial0 000000
  385.            m_ial 000007
  386.            m_ipr 00FFFF
  387.            m_rdf 000007
  388.            m_tde 000006
  389.            m_roe 000005
  390.            m_tue 000004
  391.            m_rfs 000003
  392.            m_tfs 000002
  393.            m_if1 000001
  394.            m_if0 000000
  395.             m_if 000002
  396.           m_srie 00000F
  397.           m_stie 00000E
  398.            m_sre 00000D
  399.            m_ste 00000C
  400.            m_mod 00000B
  401.            m_gck 00000A
  402.            m_syn 000009
  403.            m_fsl 000008
  404.           m_sckd 000005
  405.           m_scd2 000004
  406.           m_scd1 000003
  407.           m_scd0 000002
  408.            m_scd 00001C
  409.            m_of1 000001
  410.            m_of0 000000
  411.             m_of 000003
  412.            m_psr 00000F
  413.            m_wl1 00000E
  414.            m_wl0 00000D
  415.             m_wl 006000
  416.             m_dc 001F00
  417.             m_pm 0000FF
  418.            m_tsr 00FFEE
  419.             m_sr 00FFEE
  420.            m_crb 00FFED
  421.            m_cra 00FFEC
  422.             m_tx 00FFEF
  423.             m_rx 00FFEF
  424.            m_tcm 00000F
  425.            m_rcm 00000E
  426.            m_scp 00000D
  427.            m_cod 00000C
  428.             m_cd 000FFF
  429.             m_r8 000007
  430.             m_fe 000006
  431.             m_pe 000005
  432.             m_or 000004
  433.           m_idle 000003
  434.           m_rdrf 000002
  435.           m_tdre 000001
  436.           m_trne 000000
  437.           m_tmie 00000D
  438.            m_tie 00000C
  439.            m_rie 00000B
  440.           m_ilie 00000A
  441.             m_te 000009
  442.             m_re 000008
  443.           m_woms 000007
  444.            m_rwi 000006
  445.           m_wake 000005
  446.            m_sbk 000004
  447.           m_wds2 000002
  448.           m_wds1 000001
  449.           m_wds0 000000
  450.            m_wds 000003
  451.           m_sccr 00FFF2
  452.            m_ssr 00FFF1
  453.            m_scr 00FFF0
  454.           m_stxa 00FFF3
  455.           m_stxh 00FFF6
  456.           m_stxm 00FFF5
  457.           m_stxl 00FFF4
  458.           m_srxh 00FFF6
  459.           m_srxm 00FFF5
  460.           m_srxl 00FFF4
  461.            m_dma 000007
  462.            m_hf1 000004
  463.            m_hf0 000003
  464.             m_hf 000018
  465.            m_hcp 000002
  466.           m_htde 000001
  467.           m_hrdf 000000
  468.            m_hf3 000004
  469.            m_hf2 000003
  470.           m_hcie 000002
  471.           m_htie 000001
  472.           m_hrie 000000
  473.            m_htx 00FFEB
  474.            m_hrx 00FFEB
  475.            m_hsr 00FFE9
  476.            m_hcr 00FFE8
  477.            m_pcd 00FFE5
  478.          m_pcddr 00FFE3
  479.            m_pcc 00FFE1
  480.            m_pbd 00FFE4
  481.          m_pbddr 00FFE2
  482.            m_pbc 00FFE0
  483.            m_bcr 00FFFE
  484.              a1c 0.9914025000
  485.              a1m 0000A2
  486.              a1r 000014
  487.              a1d 006000
  488.              c3c 0.9314831000
  489.              c3m 000539
  490.              c3r 000012
  491.              c3d 005000
  492.              c2c 0.9379399000
  493.              c2m 0004B7
  494.              c2r 000011
  495.              c2d 004800
  496.              c1c 0.9500031000
  497.              c1m 0003C6
  498.              c1r 000010
  499.              c1d 004000
  500.              a2c 0.9970685000
  501.              a2m 000036
  502.              a2r 000015
  503.              a2d 006800
  504.              c4c 0.9273101000
  505.              c4m 00058E
  506.              c4r 000013
  507.              c4d 005800
  508. errors=0
  509.